Vi kører her en test:
library(ggplot2)
library(plotly)
##
## Vedhæfter pakke: 'plotly'
## Det følgende objekt er maskeret fra 'package:ggplot2':
##
## last_plot
## Det følgende objekt er maskeret fra 'package:stats':
##
## filter
## Det følgende objekt er maskeret fra 'package:graphics':
##
## layout
set_widget_hooks <- function(dep_dir, base_path,
hrefFilter = function(x) paste0("/", x)) {
# Move the dependencies into the specified folder,
# makes them relative to the base directory,
# and outputs the HTML that loads them.
render_deps <- function() {
l <- knitr::knit_meta(class = "html_dependency",
clean = FALSE)
if (length(l) > 0)
dir.create(dep_dir, showWarnings = FALSE, recursive = TRUE)
l <- lapply(unique(l), function(dep) {
dep <- htmltools::copyDependencyToDir(dep, dep_dir, FALSE)
dep <- htmltools::makeDependencyRelative(dep, base_path, FALSE)
dep } )
l <- htmltools::renderDependencies(l, hrefFilter=hrefFilter)
htmltools::htmlPreserve(l)
}
# Adds the dependency-loading HTML at the end of the doc,
# without upsetting the previous doc-hook.
prev_doc_hook <- knitr::knit_hooks$get("document")
knitr::knit_hooks$set(document = function(x) {
prev_doc_hook(append(x, render_deps()))
})
# Sets the default of all chunks to not force
# screenshots. You can change it to `TRUE`
# on the chunks you want it to screenshot.
knitr::opts_chunk$set(screenshot.force=FALSE)
}
ggplot_plot <- iris %>%
ggplot(aes(Petal.Length, Petal.Width, color=Species)) +
geom_point()
plotly_plot <- ggplotly(ggplot_plot)
plotly_plot
#<iframe src="_includes/map.html" height = "800px" width = "100%"></iframe>